home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef _CAPROXYDEBUG_
- #include "CAProxyDebug.h"
- #endif
-
-
- #ifndef _PASCALSTR_
- #include <PasclStr.h>
- #endif
-
- #include <string.h>
- #include <stdio.h>
- #include <stdarg.h>
-
- static FSSpec gLogSpec;
- static short gLogRefNum;
-
-
- static void WriteToTraceFile (char* message);
-
-
- void InitTracing(FSSpec* spec, Boolean flushLog)
- {
- FInfo ignore;
-
- if (spec == NULL)
- {
- FSMakeFSSpec (0, 2, "\pCAProxyPart Trace Log" , &gLogSpec);
- }
- else
- {
- gLogSpec = *spec;
- }
-
- if (FSpGetFInfo (&gLogSpec, &ignore))
- {
- FSpCreate (&gLogSpec, 'ttxt', 'TEXT', 0);
- }
-
- FSpOpenDF (&gLogSpec, fsRdWrPerm, &gLogRefNum);
-
- if (flushLog)
- SetEOF (gLogRefNum, 0);
-
- }
-
-
- static void WriteToTraceFile (char* message)
- {
- long count;
- char eol[2];
- long eof;
-
-
- FSpOpenDF (&gLogSpec, fsRdWrPerm, &gLogRefNum);
- GetEOF (gLogRefNum, &eof);
- SetFPos (gLogRefNum, fsFromStart, eof);
-
- count = strlen (message);
-
- FSWrite (gLogRefNum, &count, message);
-
- count = 1;
- eol[0] = 0x0D;
- FSWrite (gLogRefNum, &count, eol);
-
- FSClose(gLogRefNum);
-
-
- }
-
- void _Trace(short traceLevel, char *fmt, ... )
- {
- if (traceLevel >= TRACELEVEL)
- {
-
- char msg[512];
- strcpy(msg, "Log: ");
- va_list args;
- va_start(args,fmt);
- vsprintf(msg+strlen(msg),fmt,args);
- va_end(args);
- strcat (msg, "");
-
- WriteToTraceFile (msg);
-
-
- }
- }
-
-
-
-
-
-
-
-
-
-